from django import forms
from .models import UserProfile


class UserProfileForm(forms.Form):
    """ 用户资料表单"""

    class Meta:
        model = UserProfile
        fields = ['nickname', 'real_name', 'avatar', 'gender', 'phone', 'company', 'department']


class SignupForm(forms.Form):
    """  用户注册表单 """

    def signup(self, request, user):
        """
        用户注册
        """
        user_profile = UserProfile()
        user_profile.user = user
        user.save()
        user_profile.save()

    class Meta:
        model = UserProfile
        fields = ['username', 'password', 'email']
